<template>
  <view class="page-container">
    <scroll-view scroll-y="true" class="page-body py-20 ">
      <view class="p-20" v-if="loading && list.length>0">
        <view v-for="(item, index) in list" :key="item.id" @click="toDetail(item)"
              class="flex w-full h-full py-12 bg-ff mb-20 px-20 rounded-20">
          <view class="">
            <image :src="utils.imgFormat(item.imgUrl)" class="w-160 h-160"></image>
          </view>
          <view class="h-160 flex flex-col flex-1 justify-around">
            <view class="font-bold">{{item.title}}</view>
            <view class="font-bold text-99">{{item.contentDesc}}</view>
          </view>

        </view>
      </view>
      <up-empty marginTop="100" text="暂无排名数据" v-if="loading && list.length===0"></up-empty>
    </scroll-view>
  </view>
</template>
<script setup>
import { ref} from 'vue'
import {onLoad} from "@dcloudio/uni-app"
import utils from '@/utils/utils.js'
import  {subject} from '@/api'
import useUserStore from '@/store/user.js'
const useStore = useUserStore()
import useExam from '@/common/useExam.js'
const {
  ContentRow
} = useExam();
const list = ref([])
const loading = ref(false)
const type = ref('')
onLoad((options) => {
  if(options.type) {
    type.value = Number(options.type)
    uni.showLoading({title: '加载中'})
    subject.getSubjectTeacher({type: options.type, page: 1, limit: 100}).then(res => {
      if (res.code === 0) {
        list.value = res.data || []
        console.log('list', list.value)
      }
    }).catch(error => {
      console.log('error', error)
    }).finally(() => {
      loading.value = true
      uni.hideLoading()
    })
  }
})
const toDetail = (item) => {
  console.log('toDetail', item)
  ContentRow.value = item
  uni.navigateTo({url: `/pages/index/teacher/info?type=${type.value}`})
}
</script>
<style scoped lang="scss">
</style>